<script type="text/javascript">
	selectTab('link_submit_entry');
	$(document).ready(function(){
		/*
		var userinfo	= getcookie('userinfo');
		if( userinfo )
		{
			userinfo		= base64_decode(userinfo);
			var arrInfo		= $.parseJSON(userinfo);
			for(i in arrInfo)
			{
				if( arrInfo[i] )
				{
					$(".submit_form").find("[data-field='" + i +"']").val(arrInfo[i]);
				}
			}			
		}
		*/
		<?php if(!empty($this->index_dob)):?>
			$('input[name="candidate[<?php echo $this->index_dob;?>]"]').datepicker({
				dateFormat: 'yy-mm-dd',
				yearRange: "-50:+0",
				changeMonth: true,
				changeYear: true
			});
		<?php endif;?>
		<?php if(!empty($this->is_not_allow_to_submit)):?>
			$('input, select, textarea').attr('disabled', 'disabled');
			$('input[type=submit]').removeAttr('disabled');//for IE text color
			$('input[type=submit]').click(function(){ return false;});
		<?php else:?>
			$('input[type=submit]').click(function(){
				if($.trim($('#image').val())=='')
				{
					alert('<?php echo $this->translate('ERROR_EMPTY_IMAGE');?>');
					$('#image').focus();
					return false;
				}
				if($.trim($('#title').val())=='')
				{
					alert('<?php echo $this->translate('ERROR_EMPTY_TITLE');?>');
					$('#title').focus();
					return false;
				}
				if($('#title').val().length>255)
				{
					alert('<?php echo $this->translate('ERROR_EXCEED_MAXLENGTH_TITLE');?>');
					$('#title').focus();
					return false;
				}
                if($('#description').text().length>1000)
				{
					alert('<?php echo $this->translate('ERROR_EXCEED_MAXLENGTH_DESCRIPTION');?>');
					$('#description').focus();
					return false;
				}
				<?php
				if(!empty($this->validate_script)):
					echo $this->validate_script;
				endif;
				?>
				if(!$('#terms_and_conditions').is(':checked'))
				{
					alert('<?php echo $this->translate('MSG_AGREE_WITH_TERMS_AND_CONDITIONS');?>');
					$('#terms_and_conditions').focus();
					return false;
				}
			});
		<?php endif;?>
		$('#show_terms_and_conditions').click(function(e){
			e.preventDefault();
			var title = "<?php echo $this->translate('LABEL_TERMS_AND_CONDITIONS');?>";
			var message = '<?php echo $this->terms;?>';
			var content = message;
			var dialog = Social.getDialog().create({
				title: title,
				content: content,
				buttons:{
					Ok: function(){
						$(this).dialog("close");
					}
				}
			});
		});
	});
</script>
<?php if(isset($this->message)): ?>
    <div class="sm_message_panel">
        <p class="header"><?php echo $this->message; ?></p>
    </div>
<?php endif; ?>
<div class="submit_form">
	<div class="form_detail">
		<?php 
			$this->form->image->setDescription('Mỗi người chỉ được tham dự 1 ảnh, dung lượng tối đa không quá 2Mb. Định dạng ảnh là JPG hoặc PNG.');
			echo $this->form;
		?>
		<p><span style="color:red;">*</span>&nbsp; <span style="color:#888888">Phần bắt buộc</span></p>
	</div>
</div>


<?php echo $this->partial('index/scrollTop.phtml'); ?>